
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<span style="font-size:18px;">
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="attendance/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="attendance/css/commonly-used-show.css" />
    <script type="text/javascript" src="attendance/js/jquery.min.js"></script>
    <script type="text/javascript" src="attendance/js/bootstrap.js" ></script>

    <title>考勤查看</title>

</head>

<body class="mybody">

 <jsp:include page="theTopMenuUser.jsp" />



 <div class="container-fluid">
    <div class="row">

        <div class="col-md-12">
            <div class="col-md-12">
                    <div class="panel panel-primary">
                        <div class="panel-body">
                            <div class="alert alert-success">

                                <div>
                                     <h3 style="text-align: center">考勤记录</h3>
                                     <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3"/>

                                     <div id="personal_user" style="margin-left: 80px; margin-right: 10px;">

                                         <div class="form-group same-line">
                                             <label>年级：</label>
                                             <label id="lab_grade" class="form-control edit"></label>
                                         </div>

                                         <div class="form-group same-line-left">
                                             <label>上课星期：</label>
                                             <label id="lab_attendDate" class="form-control edit"></label>
                                         </div>

                                         <div class="form-group same-line-left">
                                             <label>上课签到时间：</label>
                                             <label id="lab_stTime" class="form-control edit"></label>
                                         </div>

                                         <div class="form-group same-line">
                                             <label>学院：</label>
                                             <label id="lab_college" class="form-control edit"></label>
                                         </div>

                                         <div class="form-group same-line-left">
                                             <label>上课时间：</label>
                                             <label id="lab_startTime" class="form-control edit"></label>
                                         </div>

                                         <div class="form-group same-line-left">
                                             <label>上课签到状态：</label>
                                             <label id="lab_stState" class="form-control edit"></label>
                                         </div>

                                         <div class="form-group same-line">
                                             <label>班级：</label>
                                             <label id="lab_class" class="form-control edit"></label>
                                         </div>

                                         <div class="form-group same-line-left">
                                             <label>下课时间：</label>
                                             <label id="lab_endTime" class="form-control edit"></label>
                                         </div>

                                         <div class="form-group same-line-left">
                                             <label>下课签到时间：</label>
                                             <label id="lab_enTime" class="form-control edit"></label>
                                         </div>

                                         <div class="form-group same-line">
                                             <label>课程：</label>
                                             <label id="lab_title" class="form-control edit"></label>
                                         </div>

                                         <div class="form-group same-line-left">
                                             <label>姓名：</label>
                                             <label id="lab_name" class="form-control edit"></label>
                                         </div>

                                         <div class="form-group same-line-left">
                                             <label>下课签到状态：</label>
                                             <label id="lab_enState" class="form-control edit"></label>
                                         </div>

                                     </div>

                                     <br>

                                     <div class="text-center same-line-clear" >
                                         <div>
                                             <label id="user_null" style="color: red"></label>
                                         </div>
                                     </div>

                                 </div>

                            </div>
                        </div>
                    </div>
                </div>
        </div>



    </div>

 </div>


<script type="text/javascript">
    var userdt = JSON.parse(sessionStorage.getItem("user"));
    var coursely = JSON.parse(sessionStorage.getItem("course"));
    var userNull = document.getElementById("user_null");
    if (userdt.result.userName != null){
        $("#usname").text(userdt.result.userName);
    }else {
        $("#usname").text(userdt.result.userLoginName);
    }


    window.onload = function(){
        checkRules();
        checkInfo();
    }


    function checkRules(){

        var postUrl = "${pageContext.request.contextPath}/member/seekClockRules";
        var str = {
            "userId": coursely.result.teacherId,
            "courseTitle": coursely.result.courseTitle
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    userNull.innerHTML = data.msg;
                }else {
                    $("#lab_grade").text(data.result.grade);
                    $("#lab_college").text(data.result.college);
                    $("#lab_class").text(data.result.classAndGrade);
                    $("#lab_title").text(data.result.courseTitle);
                    $("#lab_attendDate").text(data.result.attendDate);
                    $("#lab_startTime").text(data.result.startAttendTime);
                    $("#lab_endTime").text(data.result.endAttendTime);

                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });
    }


    function checkInfo(){

        var postUrl = "${pageContext.request.contextPath}/member/queryDayAttendanceRecord";
        var str = {
            "id": "${param.id}"
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    userNull.innerHTML = data.msg;
                }else {

                    $("#lab_name").text(data.result.userName);
                    $("#lab_stTime").text(data.result.startAttendTime);

                    if(data.result.endAttendTime != null){
                        $("#lab_enTime").text(data.result.endAttendTime);
                    }else {
                        $("#lab_enTime").text("未到时间");
                    }


                    if (data.result.startAttendState === "1"){
                        $("#lab_stState").text("正常");
                    }else if (data.result.startAttendState === "2"){
                        $("#lab_stState").text("迟到");
                    }else if (data.result.startAttendState === "3"){
                        $("#lab_stState").text("早退");
                    }else if (data.result.startAttendState === "4"){
                        $("#lab_stState").text("请假");
                    }else if (data.result.startAttendState === "5"){
                        $("#lab_stState").text("缺卡");
                    }else {
                        $("#lab_stState").text("未知");
                    }


                    if (data.result.endAttendState === "1"){
                        $("#lab_enState").text("正常");
                    }else if (data.result.endAttendState === "2"){
                        $("#lab_enState").text("迟到");
                    }else if (data.result.endAttendState === "3"){
                        $("#lab_enState").text("请假");
                    }else if (data.result.endAttendState === "4"){
                        $("#lab_enState").text("请假");
                    }else if (data.result.endAttendState === "5"){
                        $("#lab_enState").text("缺卡");
                    }else {
                        $("#lab_enState").text("未到时间");
                    }
                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });
    }

</script>

</body>
</html>
</span>